package com.thinkgsp.jxc.model;

import java.math.BigDecimal;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 盘点结果
 * @author evan
 *
 */
public class CheckResult extends BaseModel {

	private static final long serialVersionUID = 1281658323756012659L;

	private Long id;
	private Long billId;
	private Integer productId;
	private Long batchNoId;
	private Integer invAddId;
	private BigDecimal checkQty;
	private BigDecimal currentQty;
	private BigDecimal costPrice;
	private Long invId;
	
	private Product product;
	private ProductBatchNo batchNo;
	private InventoryAdd invAdd;

	
	/**
	 * @return the product
	 */
	public Product getProduct() {
		return product;
	}

	/**
	 * @param product the product to set
	 */
	public void setProduct(Product product) {
		this.product = product;
	}

	/**
	 * @return the batchNo
	 */
	public ProductBatchNo getBatchNo() {
		return batchNo;
	}

	/**
	 * @param batchNo the batchNo to set
	 */
	public void setBatchNo(ProductBatchNo batchNo) {
		this.batchNo = batchNo;
	}

	/**
	 * @return the invAdd
	 */
	public InventoryAdd getInvAdd() {
		return invAdd;
	}

	/**
	 * @param invAdd the invAdd to set
	 */
	public void setInvAdd(InventoryAdd invAdd) {
		this.invAdd = invAdd;
	}

	/**
	 * @return the currentQty
	 */
	public BigDecimal getCurrentQty() {
		return currentQty;
	}

	/**
	 * @param currentQty the currentQty to set
	 */
	public void setCurrentQty(BigDecimal currentQty) {
		this.currentQty = currentQty;
	}

	/**
	 * @return the costPrice
	 */
	public BigDecimal getCostPrice() {
		return costPrice;
	}

	/**
	 * @param costPrice the costPrice to set
	 */
	public void setCostPrice(BigDecimal costPrice) {
		this.costPrice = costPrice;
	}

	/**
	 * @return the invId
	 */
	public Long getInvId() {
		return invId;
	}

	/**
	 * @param invId the invId to set
	 */
	public void setInvId(Long invId) {
		this.invId = invId;
	}

	/**
	 * @return the billId
	 */
	public Long getBillId() {
		return billId;
	}

	/**
	 * @param billId the billId to set
	 */
	public void setBillId(Long billId) {
		this.billId = billId;
	}

	/**
	 * @return the productId
	 */
	public Integer getProductId() {
		return productId;
	}

	/**
	 * @param productId the productId to set
	 */
	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	/**
	 * @return the batchNoId
	 */
	public Long getBatchNoId() {
		return batchNoId;
	}

	/**
	 * @param batchNoId the batchNoId to set
	 */
	public void setBatchNoId(Long batchNoId) {
		this.batchNoId = batchNoId;
	}

	/**
	 * @return the invAddId
	 */
	public Integer getInvAddId() {
		return invAddId;
	}

	/**
	 * @param invAddId the invAddId to set
	 */
	public void setInvAddId(Integer invAddId) {
		this.invAddId = invAddId;
	}

	/**
	 * @return the checkQty
	 */
	public BigDecimal getCheckQty() {
		return checkQty;
	}

	/**
	 * @param checkQty the checkQty to set
	 */
	public void setCheckQty(BigDecimal checkQty) {
		this.checkQty = checkQty;
	}
	
	public BigDecimal getLossQty() {
		return this.currentQty.subtract(this.checkQty);
	}

	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("productId",this.productId)
		  .append("batchNoId",this.batchNoId)
		  .append("invAddId",this.invAddId)
		  .append("checkQty",this.checkQty)
		  .append("currentQty",this.currentQty);
		
		return sb.toString();
	}

	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof CheckResult)) {
			return false;
		}
		final CheckResult result = (CheckResult)o;
		return this.productId.equals(result.productId) && 
				this.batchNoId.equals(result.batchNoId) &&
				 this.invAddId.equals(result.invAddId) &&
				  this.billId.equals(result.billId) &&
				   this.checkQty.compareTo(result.checkQty) == 0;
	}

	@Override
	public int hashCode() {
		return this.billId.hashCode() * this.productId.hashCode() * this.batchNoId.hashCode();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

}
